<?
        require_once(__DIR__ . '/../inc/Customers.php');
        $row = GetCustomer($_REQUEST['id']);
		$id = $row['id'];
		$pay_results = GetMethod($id, 'PaymentMethods');
		$row_num_pay = $pay_results->num_rows;
		$order_results =  GetMethod($id, 'Orders'); 				
		$row_num_orders = $order_results->num_rows;
		$contact_results =  GetMethod($id, 'ContactInfo'); 				
		$row_num_contact = $order_results->num_rows;
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Details of user: <?=$row['FirstName']?> <?=$row['LastName']?></title>
    <link rel="stylesheet" type="text/css" href="../inc/bootstrap.css">
    <style type="text/css" ">
        .error { color: red; }
    </style>
</head>
<body>
        
        <? include('../inc/header.php'); ?>
        <div class="container">
                        <? include('../inc/nav.php'); ?>
            <div id="contents" style="width: 625px; float: right;">
			<table class="table table-striped table-bordered table-condensed table-hover">
                	<tr>
                    	<th>Customer Information Detail</th>
                        
                    </tr>
					</table>
                <table class="table table-striped table-bordered table-condensed table-hover">
                    <tr>
						<th>Id Number</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>created_at</th>
                        <th>update_at</th>
						<th>Access Level</th>						       			
                    </tr>
                    <tr>
						<td><?=$row['id']?></td>
					    <td><?=$row['FirstName']?></td>
                        <td><?=$row['LastName']?></td>
                        <td><?=$row['created_at']?></td>
                        <td><?=$row['updated_at']?></td>
		                <td><?=$row['AccessLevel_id']?></td>
                     </tr>
				</table>
				<table class="table table-striped table-bordered table-condensed table-hover">
                	<tr>
                    	<th>Customer Shipping Information Detail</th>
                        
                    </tr>
					</table>
				<table class="table table-striped table-bordered table-condensed table-hover">	 
					 <tr>
						<th>Address 1</th>
                        <th>Address 2</th>
                        <th>City</th>
                        <th>State</th>
                        <th>Zip Code</th>
						<th>Country</th>							       			
                    </tr>
					<tr>
						<td><?=$row['Address1']?></td>
					    <td><?=$row['Address2']?></td>
                        <td><?=$row['City']?></td>
                        <td><?=$row['State']?></td>
                        <td><?=$row['ZipCode']?></td>
					    <td><?=$row['Country']?></td>
                     </tr>
                </table>
				<table class="table table-striped table-bordered table-condensed table-hover">
                	<tr>
                    	<th>Customer Contact Info</th>
                        
                    </tr>
					</table>
					<table class="table table-striped table-bordered table-condensed table-hover">	 
					 <tr>
						<th>Info ID Number</th>
                        <th>Info Type</th>
                        <th>Info</th>						       			
                    </tr>
					<? while($rs = $contact_results->fetch_assoc()): $type_id = $rs['ContactInfoType_id'];
					$type = GetInfoType($type_id);?>
						
							<tr>					  
								<td><?=$rs['id']?></td>
								<td><?=$type['Type']?></td>						
								<td><?=$rs['Info']?></td>
							</tr>
					<? endwhile; ?>
					<? if ($row_num_contact == 0): $na = "No Registered Contact Infomation."; ?>
							<tr class="error">					  
								<td><?=$na?></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							
					<? endif ?>	
                </table>
				<table class="table table-striped table-bordered table-condensed table-hover">
                	<tr>
                    	<th>Customer Order History</th>
                        
                    </tr>
					</table>
					<table class="table table-striped table-bordered table-condensed table-hover">	 
					 <tr>
						<th>Method ID Number</th>
                        <th>Card Type</th>
                        <th>Card Number</th>
                        <th>Name On Card</th>
                        <th>Expiration Date</th>
						<th>Security Code</th>							       			
                    </tr>
					<? while($rs = $pay_results->fetch_assoc()): ?>
						
							<tr>					  
								<td><?=$rs['id']?></td>
								<td><?=$rs['CardType']?></td>						
								<td><?=$rs['CardNumber']?></td>
								<td><?=$rs['NameOnCard']?></td>
								<td><?=$rs['ExpDate']?></td>
								<td><?=$rs['SecCode']?></td>
							</tr>
					<? endwhile; ?>
					<? if ($row_num_pay == 0): $na = "No Registered Payment Method."; ?>
							<tr class="error">					  
								<td><?=$na?></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							
					<? endif ?>	
                </table>
				<table class="table table-striped table-bordered table-condensed table-hover">
                	<tr>
                    	<th>Customer Payment Methods Information Detail</th>
                        
                    </tr>
					</table>
					<table class="table table-striped table-bordered table-condensed table-hover">	 
					 <tr>
						<th>Order Number</th>
                        <th>Payment ID Number</th>
                        <th>created_at</th>
                        <th>updated_at</th>
                        <th>Shipping ID Number</th>
						<th>Shipping Date</th>
						<th>ETA</th>
						<th>Order Items</th>													       			
                    </tr>
					<? while($rs = $order_results->fetch_assoc()): ?>
						
							<tr>					  
								<td><?=$rs['id']?></td>
								<td><?=$rs['PaymentMethods_id']?></td>						
								<td><?=$rs['created_at']?></td>
								<td><?=$rs['updated_at']?></td>
								<td><?=$rs['ShippingMethods_id']?></td>
								<td><?=$rs['ShippingDate']?></td>
								<td><?=$rs['ETA']?></td>
								<td><a href="orderitems.php?id=<?=$rs['id']?>">List</a></td>
							</tr>
							</table>
							<table class="table table-striped table-bordered table-condensed table-hover">
							<tr>
								<th>Shipping Cost</th>
								<th>Sales Tax</th>
								<th>Final Price</th>
								<th>Payment Date</th>
								<th>Payment</th>
								<th>Status</th>
                   			</tr>
							<tr>
								<td><?=$rs['ShippingCost']?></td>						
								<td><?=$rs['SalesTax']?></td>
								<td><?=$rs['FinalCost']?></td>
								<td><?=$rs['PaymentDate']?></td>
								<td><?=$rs['Payment']?></td>
								<td><?=$rs['Status']?></td>						
							</tr>
					<? endwhile; ?>
					<? if ($row_num_orders == 0): $na = "No Order History."; ?>
							<tr class="error">					  
								<td><?=$na?></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							
					<? endif ?>	
                </table>
            </div>
        </div>
    </body>
</html>